
package privatemessanger;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;

/**
 * This class will manage the creat a server pop up window.
 * @author  Erez Fatal, Oren Slor, Elad Yanai, Sigal Agami, Chen Ben Shabat,
 *          Inbar Pardo, Islamm Heralla, Ziv Hadary, Oren Shalev, Ortal David.
 */
public class HostWindow
{
    private MainFrame _mainFrame;

    /**
     * Set the pop up window's size and location.
     * @param mainFrame
     */
    public HostWindow(MainFrame mainFrame)
    {
        //locate the new frame in the middle of the screen
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        int screenWidth = screenSize.width;

       JFrame frame=new JFrame("Create a new Server");
       _mainFrame=mainFrame;

        //setting up the frame
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        frame.setLocation(screenWidth / 4, screenHeight / 4);
        frame.setVisible(true);
        frame.setAlwaysOnTop(true);
        frame.setBackground(Color.white);
        frame.setSize(500, 245);

        frame.addWindowListener(new WindowAdapter()
        {
            @Override
            public void windowClosing(WindowEvent e){ _mainFrame.setVisible(true);}
        });

        HostPanel _panels = new HostPanel(frame,_mainFrame);
        frame.add(_panels);
        frame.setResizable(false);
   }
}
